/*
 * @lc app=leetcode.cn id=11 lang=csharp
 *
 * [11] 盛最多水的容器
 */

// @lc code=start
public class Solution {
    public int MaxArea(int[] height) {
        var max = 0;
        int left = 0, right = height.Length - 1;
        while (left < right)
        {
            max = Math.Max(max, (right - left) * Math.Min(height[left], height[right]));
            if (height[left] > height[right])
            {
                right--;
            }
            else
            {
                left++;
            }
        }
        return max;
    }
}

// 100 100 5 5
// @lc code=end

